| Total Complexity | 3 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | 8 | import { Controller, Post, Body, Get, UseGuards, Req } from '@nestjs/common'; |
|
| 6 | |||
| 7 | @ApiTags('auth') |
||
| 8 | @Controller({ path: 'auth', version: '1' }) |
||
| 9 | 8 | export class AuthController { |
|
| 10 | 11 | constructor(private readonly authService: AuthService) {} |
|
| 11 | |||
| 12 | @Post('token') |
||
| 13 | @ApiOperation({ summary: 'Exchange GitHub code for access token' }) |
||
| 14 | @ApiResponse({ status: 200, description: 'Token exchange successful' }) |
||
| 15 | 8 | async exchangeToken(@Body() tokenExchangeDto: TokenExchangeDto) { |
|
| 16 | 2 | return this.authService.exchangeGithubCode(tokenExchangeDto.code); |
|
| 17 | } |
||
| 18 | |||
| 19 | @Get('me') |
||
| 20 | @UseGuards(JwtAuthGuard) |
||
| 21 | @ApiBearerAuth() |
||
| 22 | @ApiOperation({ summary: 'Get current user information' }) |
||
| 23 | @ApiResponse({ status: 200, description: 'Returns user information' }) |
||
| 24 | 8 | async getMe(@Req() req) { |
|
| 25 | 1 | return req.user; |
|
| 26 | } |
||
| 27 | |||
| 28 | @Get('status') |
||
| 29 | @UseGuards(JwtAuthGuard) |
||
| 30 | @ApiBearerAuth() |
||
| 31 | @ApiOperation({ summary: 'Check authentication status' }) |
||
| 32 | @ApiResponse({ status: 200, description: 'Returns authentication status' }) |
||
| 33 | 8 | async getStatus(@Req() req) { |
|
| 34 | 1 | return this.authService.getStatus(req.user); |
|
| 35 | } |
||
| 37 |